package org.gwt.pluginframework.desktop.client;

import org.gwt.pluginframework.common.ComplexPlugin;
import org.gwt.pluginframework.common.IPluginManager;
import org.gwt.pluginframework.common.PluginManager;
import org.gwt.pluginframework.plugin.EventConsole;
import org.gwt.pluginframework.plugin.ExceptionHandlingPlugin;
import org.gwt.pluginframework.plugin.MainPerspective;
import org.gwt.pluginframework.plugin.Navigation;
import org.gwt.pluginframework.plugin.PluginMonitor;
import org.gwt.pluginframework.plugin.SplashScreen;
import org.gwt.pluginframework.plugin.StatusBar;
import org.gwt.pluginframework.plugin.TabManagerPlugin;

import com.google.gwt.core.client.EntryPoint;

public class DesktopApplication implements EntryPoint {
	
	IPluginManager manager;
	
	public void onModuleLoad() {
		manager = new PluginManager();
		
		// splash screen - when created window is shown
		manager.registerPlugin(new SplashScreen());
		
		// logs any events and other messages (should be created as soon as possibly
		EventConsole console = new EventConsole();
		manager.registerPlugin(console, false);
		
		//manager.registerPlugin(new BasicExceptionHandler());
		
		// we dont want to start plugin monitor at start
		manager.registerPlugin(new PluginMonitor(), false);

		ComplexPlugin perspective = new MainPerspective();
		manager.registerPlugin(perspective);
		
		Navigation navigation = new Navigation();
		manager.registerPlugin(navigation);
		
		TabManagerPlugin tab = new TabManagerPlugin();
		manager.registerPlugin(tab);
		
		FormA formA = new FormA();
		manager.registerPlugin(formA, false);
		
		FormB formB = new FormB();
		manager.registerPlugin(formB, false);
		
		manager.registerPlugin(new ExceptionHandlingPlugin());
		manager.registerPlugin(new FormCFactory(), false);
		manager.registerPlugin(new FormCTab1(), false);
		manager.registerPlugin(new FormCTab2(), false);
		
		StatusBar statusBar = new StatusBar();
		manager.registerPlugin(statusBar);
		
		perspective.registerExtension(MainPerspective.NORTH_EXTENSION_POINT, new TopBar());
		perspective.registerExtension(MainPerspective.WEST_EXTENSION_POINT, navigation);
		perspective.registerExtension(MainPerspective.SOUTH_EXTENSION_POINT, statusBar);
		perspective.registerExtension(MainPerspective.CENTER_EXTENSION_POINT, tab);

		manager.run();
	}
}
